package helper.scxml.scxml2.zone.t2.case3_factoryLines

import helper.base.BaseTypeHelper.isInt
import helper.base.FunArgHelperKt.FunArgHelper
import helper.base.TupleHelper.GetTuple.getA2Tuple
import helper.scxml.scxml2.zone.t2.ConfigHelper.Config
import helper.scxml.scxml2.zone.t2.case3_factoryLines.FLEnvHelper.FLEnv
import helper.scxml.scxml2.zone.t2.case3_factoryLines.FLEnvHelper.FLEnv.Companion.aPMs
import helper.scxml.scxml2.zone.t2.case3_factoryLines.FLEnvHelper.ProductionMachine

object FunArgHelperKt {
    object ZoneStateStringFunArgHelper : FunArgHelper<(Config) -> String>() {
        val startWith_ = "startWith_"
        val aPMsFunList = aPMs.map { aProductionMachine: ProductionMachine ->
            val sMi = aProductionMachine.name
            getA2Tuple("$startWith_$sMi") { config: Config ->
                config.states.first {
                    it.startsWith(sMi)
                }
            }
        }

        val aTStringFun = getA2Tuple("aTStringFun") { zs: Config ->
            val nowDoubleT = zs.getTTime()
            require(nowDoubleT.isInt())
            val nowT = nowDoubleT.toInt()
            val nowTString = nowT.toString()
            nowTString
        }
        override val list = aPMsFunList + listOf(aTStringFun)

        fun aForMachineGetZoneStateFunction(sMi: String): (Config) -> String {
            return getValueFromStringELHM("$startWith_$sMi")
        }

        @JvmStatic
        fun main(args: Array<String>) {
            this.printMappings()
        }
    }

    object ZoneStateStringLHSFunArgHelper : FunArgHelper<(Config) -> LinkedHashSet<String>>() {
        val aFLEnvPMNames = { _: Config ->
            LinkedHashSet(FLEnv.aPMNames)
        }
        override val list = listOf(
            getA2Tuple("aFLZoneEnvPMNames", aFLEnvPMNames),
        )
    }

    @JvmStatic
    fun main(args: Array<String>) {
        println(FLEnv.aPMNames)
    }
}